package com.thinkcube.edutainment.adapters;

import java.util.List;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.thinkcube.edutainment.domain.data.OtherForumData;
import com.thinkcube.edutainment.service.viewitem.OtherForumPostItem;
import com.thinkcube.edutainment.service.viewitem.OtherForumPostItem_;

@EBean
public class OtherForumPostAdapter extends BaseAdapter {

	List<OtherForumData> otherForumData;

	@RootContext
	Context context;

	@Override
	public View getView(final int position, final View convertView,
			final ViewGroup parent) {

		OtherForumPostItem otherForumPostItem;
		if (convertView == null) {
			otherForumPostItem = OtherForumPostItem_.build(context);
		} else {
			otherForumPostItem = (OtherForumPostItem) convertView;
		}

		otherForumPostItem.bind(getItem(position));

		return otherForumPostItem;
	}

	public List<OtherForumData> getOtherForumData() {
		return otherForumData;
	}

	public void setOtherForumData(List<OtherForumData> otherForumData) {
		this.otherForumData = otherForumData;
	}

	@Override
	public int getCount() {
		return otherForumData.size();
	}

	@Override
	public OtherForumData getItem(final int position) {
		return otherForumData.get(position);
	}

	@Override
	public long getItemId(final int position) {
		return position;
	}

}
